from Data import Data
from MetaData import MetaData
import activist.Time

##
## instances of this are intended to be used for
## generic targets of metadata. for instance, one
## might want to "highlight" events; to do so,
## one might create a GenericData('highlighted events')
## and link highlighted events to it.
##
## Of course, something would need to keep a reference
## to the right object...perhaps we'll need a global
## configuration-type object?
##


class GenericData(Data):
    def __init__(self,expectedid=None):
        super(GenericData,self).__init__(expectedid)
        self.command("create")
        
    command_create_VERSION = 0
    def command_create(self,title):
        self._createcalled = True
        self._title = title
        from activist.DataStore import DataStore
        DataStore._objs[title] = self
        
    def title(self):
        return self._title

    def __str__(self):
        return '<GenericData-%s: "%s">' % (self.id(),self._title)
    
    def getXML(self):
        return """
<genericdata class="activist.GenericData" id="%(id)s">
  <title>%(title)s</title>
%(meta)s
</genericdata>
        """ % { "id":self.id(),
                "title":self.title(),
                "meta":self.getMetaXML()
                }

    
